import { defineStore } from "pinia";
import { getClientOss, getProgress } from "@/utils/aliOssUpload";

const useMultipartOssStore = defineStore("oss", {
  state: () => ({
    loadingArr: {},
    completeState: {}
  }),
  actions: {
    async submit(ObjName, fileData, uid) {
      const client = await getClientOss();
      const options = {
        progress: (p, cpt, res) => {
          this.loadingArr[uid] = getProgress(p);
        },
        parallel: 4,
        partSize: 1024 * 1024,
        headers: {}
      };
      return await client.multipartUpload(ObjName, fileData, options);
    }
  }
});
export default useMultipartOssStore;
